<template>
  <div class="app">
    <h1>我是 爷爷</h1>

    <button @click="onUnbind">解绑</button>

    <HelloFatherVue />
  </div>
</template>

<script>
import HelloFatherVue from "./components/HelloFather.vue";

export default {
  name: "App",

  components: {
    HelloFatherVue,
  },

  methods: {
    onUnbind() {
      // 使用 eventBus 解绑一个事件

      this.$eventBus.$off("xxx", this.xxxFn);
    },

    xxxFn(number) {
      alert(`xxx 事件被执行了${number}`);
    },
  },

  mounted() {
    console.log(this);

    // 使用 eventBus 绑定一个事件
    this.$eventBus.$on("xxx", this.xxxFn);
  },
};
</script>
